package com.mashibing.net.bio;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @description:
 * @author: 余希瑶
 * @date: 2021年06月24日 15:47
 * @version:1.0
 */
public class Server {
    public static void main(String[] args) throws Exception{
        ServerSocket ss = new ServerSocket();
        ss.bind(new InetSocketAddress("localhost",8888));

        boolean started =true;
        while(started){
            //阻塞方法
            Socket socket = ss.accept();

            System.out.println("hello");
            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            System.out.println(reader.readLine());

            reader.close();
            socket.close();
        }

        ss.close();
    }
}
